import request from '@/utils/request'

// 获取工资统计数据
export function getSalaryStat(params) {
  return request({
    url: '/api/salary/stat',
    method: 'get',
    params
  })
}

// 获取考勤数据
export function getAttendances(params) {
  return request({
    url: '/api/salary/attendances',
    method: 'get',
    params
  })
}

// 获取工资统计
export function getSalaryStats(params) {
  return request({
    url: '/api/salary/stat',
    method: 'get',
    params
  })
}

// 删除计件工资记录
export function deleteType1Record(id) {
  return request({
    url: `/api/work-records/type1/${id}`,
    method: 'delete'
  })
}

// 删除特殊工资记录
export function deleteType2Record(id) {
  return request({
    url: `/api/work-records/type2/${id}`,
    method: 'delete'
  })
}

// 批量删除计件工资记录
export function batchDeleteType1(ids) {
  if(ids.length === 1) {
    return request({
      url: `/api/work-records/type1/${ids[0]}`,
      method: 'delete'
    })
  }else{
    return request({
      url: '/api/work-records/type1/batch',
      method: 'delete',
      data: ids
    })
  }
}

// 批量删除特殊工资记录
export function batchDeleteType2(ids) {
  if(ids.length === 1) {
    return request({
      url: `/api/work-records/type2/${ids[0]}`,
      method: 'delete'
    })
  }else{
    return request({
      url: '/api/work-records/type2/batch',
      method: 'delete',
      data: ids 
    })
  }
}

const handleSelectionChange = (selection) => {
  selectedRecords.value = selection
} 